/*
 *  Laboratorio de Finanzas Computacionales
 */

package bm.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

import bm.data.Libro;


public class VerLibro extends Action {
    
    
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        
        int id_libro = new Integer(request.getParameter("id")).intValue();
        
        Libro libro = this.getLibro(id_libro);
        
        request.setAttribute("libro", libro);
        
        return mapping.findForward("success");
    }
    
    
    
    private Libro getLibro(int id_libro) {
        
        if (id_libro == 1){
            
            Libro libro = new Libro();
            libro.setTitulo("El Hobbit");
            libro.setAutor("Tolkien");
            libro.setPaginas(368);
            
            return libro;
            
        }else{
            
            return null;
        }
    }
}


